import axios from "axios";
import JSEncrypt from "jsencrypt";
let encrypt = new JSEncrypt();
encrypt.setPublicKey(
  "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtP1MKTZj5Hx1hxG3VgGpC5e/O21uHMjSvRYOjmhNuc+VaN8Hr29+gnbLA89O3IGIAcmj9aqkXK1zoxsNAjRXb32B92+/2/rkhNN2IK2pBgyTgQO1Hb66BifzIOEjK8/rSpcueZ19CJY0Rh0GesDBhVZJ1FpLF9O5+kEyAe3Q9FwIDAQAB"
);
var baseurl = process.env.VUE_APP_API_URL;
const api = axios.create({
  baseURL: baseurl,
});
api.interceptors.request.use((config) => {
  config.headers = {
    Xs_token:localStorage.getItem("logintoken"),
    sign: encrypt.encrypt(
      JSON.stringify({
        timeStamp: new Date().getTime(),
        requestId: Math.floor(100000000 + Math.random() * 900000000),
      })
    ),
  };
  return config;
});
export default api;
